home *** CD-ROM | disk | FTP | other *** search
- Path: lrz-muenchen.de!news
- From: watzka@stat.uni-muenchen.de (Kurt Watzka)
- Newsgroups: comp.lang.c
- Subject: Re: Settle a bet please
- Date: 1 Apr 1996 21:00:32 GMT
- Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
- Distribution: world
- Message-ID: <4jpg5g$6i@sparcserver.lrz-muenchen.de>
- References: <4jfopb$o9n@news1.sympatico.ca> <4jh8rtINNosd@mayne.ugrad.cs.ubc.ca> <4jp8li$ue@eri2.erinet.com>
- NNTP-Posting-Host: sun2.lrz-muenchen.de
-
- timb@erinet.com (Tim Berens) writes:
-
- >Here's an interesting way to decide for yourselves:
-
- >main()
- >{
- > printf("size is: %d",sizeof("My Name"));
- >}
-
- >This will display how many bytes your compiler thinks should be
- >allocated for "My Name"
-
- If size_t is defined as int (which it cannot be, because it is an
- unsigned quantity) this will always work. However, if you have to
- print something, and all you can possibly know about it is that it
- is an unsigned integer type, it might be better to cast it to and
- print it as a type that can hold all values of unsigned integer
- types:
-
- printf("size is %lu\n", (unsigned long) sizeof("My Name"));
-
- Kurt
- --
- | Kurt Watzka Phone : +49-89-2180-6254
- | watzka@stat.uni-muenchen.de
-
-